package leetcode_贪心;

/**
 * @author yzh
 * @data 2021/3/30 21:55
 * 局部最优解：后一天减去前一天，如果是正数的，就算上
 */
public class _122_买股票II {

    public int maxProfit(int[] prices) {
        int ans = 0;
        for (int i = 1; i < prices.length; i++) {
            int tem = prices[i] - prices[i - 1];
            if (tem > 0) ans += tem;
        }
        return ans;
    }
}
